unit uReport;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, Grids, DBGridEh, StdCtrls, ExtCtrls;

type
  TfReport = class(TForm)
    GroupBox1: TGroupBox;
    DBGridEh5: TDBGridEh;
    tbOperationParamColor: TToolBar;
    tbAddOperationParamColor: TToolButton;
    tbDelOperationParamColor: TToolButton;
    OpenDialog1: TOpenDialog;
    procedure DBGridEh5Columns1EditButtons0Click(Sender: TObject;
      var Handled: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure DBGridEh5KeyPress(Sender: TObject; var Key: Char);
    procedure tbAddOperationParamColorClick(Sender: TObject);
    procedure tbDelOperationParamColorClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fReport: TfReport;

implementation

uses uDBData;

{$R *.dfm}

procedure TfReport.DBGridEh5Columns1EditButtons0Click(Sender: TObject;
  var Handled: Boolean);
begin
  if(OpenDialog1.Execute)then
  begin
    fDBData.dReport.DataSet.FieldByName('FileName').Value := ExtractFileName(OpenDialog1.FileName);
  end;
end;

procedure TfReport.FormCreate(Sender: TObject);
begin
  OpenDialog1.InitialDir := ExtractFileDir(Application.ExeName) + '\reports';
end;

procedure TfReport.DBGridEh5KeyPress(Sender: TObject; var Key: Char);
begin
  if(Key = #13) then (Sender as TDBGridEh).DataSource.DataSet.Post();
end;

procedure TfReport.tbAddOperationParamColorClick(Sender: TObject);
begin
  fDBData.InsertRecord(fDBData.dReport);
end;

procedure TfReport.tbDelOperationParamColorClick(Sender: TObject);
begin
  fDBData.DeleteRecord(fDBData.dReport);
end;

end.
